package com.alibaba.cloudalibabaserver.repository;


import com.alibaba.cloudalibabaserver.bean.Order;
import com.alibaba.cloudalibabaserver.bean.OrderDetail;
import com.alibaba.cloudalibabaserver.bean.OrderItem;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface OrderItemRepository extends JpaRepository<OrderItem, Long> {

    // 在 MyBatis Mapper 中的示例
    @Query("SELECT o.orderId FROM Order o JOIN OrderItem i ON o.orderId = i.orderId WHERE o.userId = :userId")
    List<OrderDetail> selectOrderDetailByUserId(@Param("userId") Long userId);
}